package main

import (
	"os"

	"gitee.com/smewl13/beehive/cmd"
	"gitee.com/smewl13/beehive/internal/encrypt"
	"github.com/urfave/cli/v2"
)

func main() {
	app := cli.App{
		Name:  "encrypt",
		Usage: "获取公网地址,发送企业微信或邮件信息通知",
		Flags: []cli.Flag{
			&cli.BoolFlag{
				Name:               "version",
				Aliases:            []string{"v"},
				Usage:              "打印版本号",
				DisableDefaultText: true,
			},
		},
		Action: func(ctx *cli.Context) error {
			if ctx.Bool("version") {
				cmd.Version()
			}
			return nil
		},
		Commands: []*cli.Command{
			{
				Name:  "sm4encode",
				Usage: "对明文内容使用sm4算法加密,输出加密结果",
				Flags: []cli.Flag{
					&cli.StringFlag{
						Name:    "config",
						Aliases: []string{"c"},
						Value:   "configs/config.toml",
					},
				},
				Action: func(ctx *cli.Context) error {
					app := encrypt.NewAPP("sm4.encode", ctx)
					app.Run()
					return nil
				},
			},
			{
				Name:  "sm4decode",
				Usage: "对明文内容使用sm4算法加密,输出加密结果",
				Flags: []cli.Flag{
					&cli.StringFlag{
						Name:    "config",
						Aliases: []string{"c"},
						Value:   "configs/config.toml",
					},
				},
				Action: func(ctx *cli.Context) error {
					app := encrypt.NewAPP("sm4.decode", ctx)
					app.Run()
					return nil
				},
			},
		},
	}

	app.Run(os.Args)
}
